import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'
import { TerminalListComponent } from './list/list.component'
import { TerminalNewComponent } from './new/new.component'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { TerminalDetailComponent } from './detail/detail.component'
import { TerminalDetailTabSystemComponent } from './detail/tab-system/tab-system.component'
import { TerminalDetailTabTransactionComponent } from './detail/tab-transaction/tab-transaction.component'
import { TerminalDetailTabReceiveCodeComponent } from './detail/tab-receive-code/tab-receive-code.component'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  {
    path: 'terminals',
    redirectTo: 'terminals/list',
    pathMatch: 'full',
  },
  {
    path: 'terminals/list',
    component: TerminalListComponent,
    canActivate: [ListReuseGuardClass],
    data: {
      title: '终端列表',
      titleI18n: 'MENU.BIZ.TERMINALS',
      reuse: true,
    },
  },
  {
    path: 'terminals/new',
    component: TerminalNewComponent,
    canDeactivate: [ NewRouterGuardClass ],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.CREATE',
      titleI18n: 'BIZ.TERMINAL.TITLE.CREATE',
    },
  },
  {
    path: 'terminals/:termCode/of/:intStoreCode',
    component: TerminalDetailComponent,
    children: [
      { path: '', redirectTo: 'qrcode', pathMatch: 'full' },
      {
        path: 'qrcode',
        component: TerminalDetailTabReceiveCodeComponent,
        data: {
          titleI18n: 'BIZ.TERMINAL.TITLE.DETAIL',
        },
      },
      {
        path: 'systems',
        component: TerminalDetailTabSystemComponent,
        data: {
          titleI18n: 'BIZ.TERMINAL.TITLE.DETAIL',
        },
      },
      {
        path: 'transactions',
        component: TerminalDetailTabTransactionComponent,
        data: {
          titleI18n: 'BIZ.TERMINAL.TITLE.DETAIL',
        },
      },
    ],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL',
      titleI18n: 'BIZ.TERMINAL.TITLE.DETAIL',
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TerminalRoutingModule { }
